// Modelo.js
Application.Modelo = Backbone.Model.extend({
    validate: function (attr) {
        var
            field, 
            rule, 
            errors = [],
            ruleValues;
        
        for (field in this.rules) {
            for (rule in this.rules[field]) {
                ruleValues = [attr[field]];

                // Set the 
                if (this.rules[field][rule].hasOwnProperty('length')) {
                    ruleValues.concat(this.rules[field][rule]);
                } else {
                    ruleValues.push(this.rules[field][rule]);
                }

                
                if (!Application.Validation.Rule[rule].prototype.constructor.apply(this, ruleValues)) {
                    errors.push(
                        Application.Validation.Message.getMessage(
                            rule,
                            field,
                            this.rules[field][rule]
                        )
                    );
                }
            }
        }

        return errors.length > 0 ? errors : false;
    }
});
